#ifndef __WIFI_TCP_H__
#define __WIFI_TCP_H__

#include <stdbool.h>

#define LOG_TAG "tcp"
#define BUFF_LEN 256

// #define OC_SERVER_IP "192.168.29.30"
// #define SERVER_PORT 7888

#define OC_SERVER_IP "118.89.53.22"
#define SERVER_PORT 7888

#define IOT_CMD_LIGHT_ON 0x01
#define IOT_CMD_LIGHT_OFF 0x02
#define IOT_CMD_MOTOR_ON 0x03
#define IOT_CMD_MOTOR_OFF 0x04
#define IOT_CMD_AUTO_ON 0x05
#define IOT_CMD_AUTO_OFF 0x06

#define MAX_BUFFER_LENGTH 512 // 定义最大缓冲区长度，用于发送和接收数据
#define MAX_STRING_LENGTH 64  // 定义最大字符串长度，用于存储设备ID等信息

typedef struct
{
    double illumination;
    double temperature;
    double humidity;
    double ppm;
    bool motor_state;
    bool light_state;
    bool auto_state;
} tcp_data;

typedef struct tcp_alarm
{
    bool alarm_state;
    bool ppm_alarm_state;
    bool humidity_alarm_state;
} tcp_alarm_t;

int tcp_client_init(void);
unsigned int tcp_send_data(tcp_data *iot_data); // 发数据
unsigned int tcp_send_alarm(tcp_alarm_t *alarm); // 发警报

void tcp_receive_data(void);

#endif